package pkg

import (
	"context"
	"github.com/qiniu/go-sdk/v7/storagev2/credentials"
	"github.com/qiniu/go-sdk/v7/storagev2/http_client"
	"github.com/qiniu/go-sdk/v7/storagev2/uploader"
)

func Qiniuyun(flse string) (string, error) {
	accessKey := "p0KFVieAO2IWI1r-eqKNyIo-mTV7E6TlT8-o5Ka9"
	secretKey := "Nbm8oGZMIazztmvyFmWKY2Ts0wcs6ZLW0qpuLuoI"
	mac := credentials.NewCredentials(accessKey, secretKey)
	bucket := "zhaozhangxu"
	key := "github-x.png"
	uploadManager := uploader.NewUploadManager(&uploader.UploadManagerOptions{
		Options: http_client.Options{
			Credentials: mac,
		},
	})
	err := uploadManager.UploadReader(context.Background(), flse, &uploader.ObjectOptions{
		BucketName: bucket,
		ObjectName: &key,
		CustomVars: map[string]string{
			"name": "github logo",
		},
		FileName: key,
	}, nil)

	return "http://t36f55lc8.hn-bkt.clouddn.com/" + key, err
}
